﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using RN.ERP.Web.PersonService;
using RN.ERP.Web.ModelService;
using Newtonsoft.Json;
using Telerik.Web.UI;
using RN.ERP.Web.Utilities;

namespace RN.ERP.Web.UserControl
{
    public partial class UCUserLog : BaseUserControl
    {
        public string ObjectId { get; set; }
        public string AreaCode { get; set; }
        public string CodeType { get; set; }
        protected void Page_Load(object sender, EventArgs e)
        {
            
        }

        protected void RadGridLog_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
        {
            PersonServiceClient client = new PersonServiceClient();
            var logsCount = client.GetUserLogCount(ObjectId, UserInfo.RoleType, AreaCode);
            var logs = JsonConvert.DeserializeObject<List<User_Log>>(client.GetUserLogList(RadGridLog.CurrentPageIndex + 1, RadGridLog.PageSize, ObjectId, UserInfo.RoleType, AreaCode));
            RadGridLog.AllowCustomPaging = true;
            RadGridLog.VirtualItemCount = logsCount;
            RadGridLog.DataSource = logs;
        }
    }
}